package books.to.africa

class Book {
	String title
	String author
	String quantity
	String description
	String ISBN
	String minGradeLevel
	String maxGradeLevel
	String language
	String category
	String ranking
	Date dateListed = new Date()
	
	static belongsTo = [ DonationList, InventoryList, FillList, DonorRegister ] // 

	
	static constraints = {
		title(blank:false)
		author(blank:false)
		quantity(blank: false)
		description(nullable: true, maxSize: 1000)
		ISBN(nullable: true, matches: /^(97(8|9)(-)?)?\d{1}(-)?\d{2}(-)?\d{6}(-)?(\d|X)$/)
		minGradeLevel(blank: false, inList: ["0", "1", "2", "3", "4", "5", "6"])
		maxGradeLevel(blank: false, inList: ["0", "1", "2", "3", "4", "5", "6"], validator:
			{entry, inst -> return entry >= inst.minGradeLevel})
		language(nullable: true)
		category(blank: false, inList: ["General Leisure Reading", "Reading Skills", "Math Skills", "Health", "Science"])
		ranking(nullable: true, inList: ["1", "2", "3", "4", "5"])
	}
	
}
